package com.stock.stockana;

import android.content.Context;

import com.android.volley.Request;
import com.android.volley.toolbox.ImageLoader;
import com.stock.publiclib.LibCenter;
import com.stock.publiclib.model.UserService;
import com.stock.publiclib.utils.DeviceUuidUtil;
import com.stock.stockana.model.StockService;

/**
 * ---------------------------------------------------
 * Description:
 * Author: ljgsonx
 * Belong to: com.stock.stockana
 * Time: 2016/1/26 10:00
 * ---------------------------------------------------
 */
public class StockCenter extends LibCenter {

    private static StockCenter stockCenter;
    private static DeviceUuidUtil deviceUuidUtil;

    public static void init(Context context,String db_name, int version){
        mContext = context;
        commondb_name = db_name;
        mVersion = version;
        stockCenter = new StockCenter();
        deviceUuidUtil = new DeviceUuidUtil(mContext);
        StockService.copyDBFromAsset(context);
    }

    private StockCenter(){}

    private static StockCenter getStockCenter(){
        if(null == stockCenter)
            stockCenter = new StockCenter();
        return stockCenter;
    }

    public static String getDeviceUUID() {
        getStockCenter();
        return deviceUuidUtil.getDeviceUuid().toString();
    }

    public static StockService getStockService() {
        return StockService.getInstance();
    }

    public static void doReq(Request request){
        getStockCenter().doNetWorkReq(request);
    }

    public static UserService getUserDB(){
        return getStockCenter().getUserService();
    }

    public static ImageLoader getImageLoader() {
        return getStockCenter().getDefaultImageLoader();
    }

}
